package admin

import (
	"goTong/app/hlw/admin/config"
	"goTong/gtong/core/trace"
	"goTong/gtong/server/restserver"
)

func NewAdminHTTPServer(cfg *config.Config) (*restserver.Server, error) {
	//初始化open-telemetry的exporter
	trace.InitAgent(trace.Options{
		cfg.Telemetry.Name,
		cfg.Telemetry.Endpoint,
		cfg.Telemetry.Sampler,
		cfg.Telemetry.Batcher,
	})
	urpcRestServer := restserver.NewServer(
		restserver.WithPort(cfg.Server.HttpPort),
		restserver.WithMiddlewares(cfg.Server.Middlewares),
		restserver.WithEnableProfiling(true),
		restserver.WithMetrics(true),
	)
	//配置好路由
	initRouter(urpcRestServer)
	return urpcRestServer, nil
}
